package com.yvpi.yvpicturebackend.exception;

/**
 * 异常处理类
 */
public class ThrowUtils {
    /**
     * 条件抛异常
     * @param condition
     * @param runtimeException
     */
    public static void throwIf(boolean condition,RuntimeException runtimeException){
        if (condition){
            throw runtimeException;
        }
    }

    /**
     *
     * @param condition
     * @param errorCode
     */
    public static void throwIf(boolean condition,ErrorCode errorCode){
       throwIf(condition,new BusinessException(errorCode));
    }

    /**
     *
     * @param condition
     * @param errorCode
     * @param message
     */
    public static void throwIf(boolean condition,ErrorCode errorCode,String message){
        throwIf(condition,new BusinessException(errorCode,message));
    }
}
